#!/bin/bash
# 初始化参数信息
JavaHomePath="/home/www/data/jdk1.8.0_241"
TomcatPath="/home/www/data/apache-tomcat-9.0.34"

echo "JDK路径:"${JavaHomePath}" Tomcat部署路径:"${TomcatPath}

# 重置JAVA环境变量
export JAVA_HOME="/home/www/data/jdk1.8.0_241"
export CLASSPATH=.:${JAVA_HOME}/jre/lib/rt.jar:${JAVA_HOME}/lib/dt.jar:${JAVA_HOME}/lib/tools.jar
export PATH=$PATH:${JAVA_HOME}/bin

# Google翻译凭据的 JSON 文件的路径
export GOOGLE_APPLICATION_CREDENTIALS="/home/www/data/apache-tomcat-9.0.34/webapps/EliteGeneralHttpTask/WEB-INF/classes/GoogleAPI.json"

# 将Tomcat进程Kill掉
kill -9 `ps -ef | grep ${TomcatPath}|grep java|awk '{print $2}'`
echo "Tomcat进程已完成Kill..."

# 静默方式启动Tomcat
cd $TomcatPath/bin
nohup ./startup.sh 1> $TomcatPath/logs/catalina.out 2> $TomcatPath/logs/catalina.err &

echo "Tomcat启动完成,等待输出日志..."

#检查启动日志是否输出,输出后Tail方式打开
sleep 3s
tail -Fn100 $TomcatPath/logs/catalina*.out
